 #include<stdio.h>
 #include<math.h>
 main()
 {
 	float a = -1,b = 1,h;
 	int i,j,ch,n=100,count1=1,count2=1,count3=1,count4=1;
	
	//float tolerence = 0.0001; 
	float F1(float x);
	float F2(float x);
	float F3(float x);
	float F4(float x);
	float F11(float x);
	float F21(float x);
	float F31(float x);
	float F41(float x);
	
	h = (float)1/(float)n ;
	while(1)
	{
	
	printf("\n 1. When F(x) = (2x^2 -1) .");
	printf("\n 2. When F(x) = (4x^3 - 3x) .");
	printf("\n 3. When F(x) = (8x^4 - 8x^2 + 1) .");
	printf("\n 4. When F(x) = (16x^5 - 20x^3 + 5x) .");
	printf("\n Enter your choice ( 0 to exit) :");
	scanf("%d",&ch);
	switch(ch)
	{
	case 1 :
		
		//float X1[2];
		count1=1;
		for(a=-1;a < b; a=a+h)
		{
			if( F1(a)*F1(a+h) < 0)//tolerence)
			{
				
				printf("\nThe %d root is --> %.6f",count1,(float)(a-(F1(a)/F11(a))));
				count1=count1+1;
			}
			
		}
		
		break;
	case 2 :
		count2=1;
		for(a=-1;a < b; a=a+h)
		{
			if( F2(a)*F2(a+h) < 0)//tolerence)
			{
				
				printf("\nThe %d root is --> %.6f",count2,(float)(a-(F2(a)/F21(a))));
				count2=count2+1;
				
			}
			
		}
		
		break;
	case 3 :
		count3=1;
		for(a=-1;a < b; a=a+h)
		{
			if( F3(a)*F3(a+h) < 0)//tolerence)
			{
				
				printf("\nThe %d root is --> %.6f",count3,(float)(a-(F3(a)/F31(a))));
				count3=count3+1;
				
			}
			
		}
		break;
	case 4 :
		count4=1;
		for(a=-1;a < b; a=a+h)
		{
			if( F4(a)*F4(a+h) < 0)//tolerence)
			{
				
				printf("\nThe %d root is --> %.6f",count4,(float)(a-(F4(a)/F41(a))));
				count4=count4+1;
				
			}
			
		}		break;
	default : 
		printf("BYE");
		exit(0);
	}
	}
	
}
 float F1(float x)
 {
 	return (float)(2*x*x - 1);
 }
 float F2(float x)
 {
 	return (float)(4*x*x*x-3*x);
 }
 float F3(float x)
 {
 	return (float)(8*x*x*x*x-8*x*x+1);
 }
 float F4(float x)
 {
 	return (float)(16*x*x*x*x*x-20*x*x*x+5*x);
 }
 float F11(float x)
 {
 	return (float)(4*x);
 }
 float F21(float x)
 {
 	return (float)(12*x*x-3);
 }
 float F31(float x)
 {
 	return (float)(32*x*x*x-16*x);
 }
 float F41(float x)
 {
 	return (float)(80*x*x*x*x-60*x*x+5);
 }
